fix: Add app_id field to the t_component_library table#220
fix: Add app_id field to the t_component_library table#220hexqi merged 4 commits intoopentiny:developfrom
Conversation
WalkthroughA new nullable integer column Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Service
participant DB
User->>Service: Create/Update ComponentLibrary (with appId)
Service->>DB: INSERT/UPDATE t_component_library (includes app_id)
DB-->>Service: Acknowledge
Service-->>User: Operation result
User->>Service: Query ComponentLibrary
Service->>DB: SELECT ... FROM t_component_library (includes app_id)
DB-->>Service: Result with app_id
Service-->>User: ComponentLibrary data (with appId)
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql (1)
654-654: Duplicate: consider adding a foreign key and index forapp_id
See the H2 schema review above for recommendations on enforcing referential integrity and improving query performance by indexingapp_id.
🧹 Nitpick comments (5)
base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java (1)
44-44: Expanded automatic field filling to include tenantIdThe addition of
tenantIdto the automatic field filling mechanism is a good enhancement that ensures consistent tenant data across entities. This change aligns with the existing pattern in the handler class.Consider adding a comment explaining why tenantId is being handled differently with
fillStrategyinstead ofsetFieldValByNamelike the other fields.app/src/main/resources/sql/mysql/update_all_tables_ddl.sql (1)
31-31: New app_id column added to t_component_library tableThis change adds the app_id field to the component library table in the MySQL database, consistent with the H2 schema update.
Ensure that similar changes are made to any other database scripts in the codebase, such as initial schema creation scripts, to maintain consistency across all environments.
app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql (1)
654-654: Consider adding a foreign key and index forapp_id
Right nowapp_idis a plain nullable column; enforcing referential integrity with a foreign key constraint referencingt_app(id)and adding an index onapp_idcan improve data integrity and query performance.base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java (1)
47-48: Explicitly mapappIdwith @TableField
Consider adding@TableField("app_id")above theappIdfield to make the column-to-property mapping explicit and guard against future naming-strategy changes.base/src/main/resources/mappers/ComponentLibraryMapper.xml (1)
10-12: Wrapapp_idin backticks for consistency
Other column names likename,public, andothersare backticked; wrappingapp_idas`app_id`ensures consistent escaping and avoids potential case-sensitivity or reserved-word issues.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
app/src/main/resources/sql/h2/create_all_tables_ddl_v1.h2.sql(1 hunks)app/src/main/resources/sql/h2/update_all_tables_ddl.sql(1 hunks)app/src/main/resources/sql/mysql/create_all_tables_ddl_v1.mysql.sql(1 hunks)app/src/main/resources/sql/mysql/update_all_tables_ddl.sql(1 hunks)base/src/main/java/com/tinyengine/it/common/handler/MyMetaObjectHandler.java(1 hunks)base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java(1 hunks)base/src/main/resources/mappers/ComponentLibraryMapper.xml(8 hunks)base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java(1 hunks)
🔇 Additional comments (6)
base/src/test/java/com/tinyengine/it/common/handler/MyMetaObjectHandlerTest.java (1)
39-39: Test verification correctly updated for new fieldThe updated assertion correctly accounts for the additional
hasSettercall introduced by the newtenantIdfill operation.base/src/main/resources/mappers/ComponentLibraryMapper.xml (5)
22-24: Conditional filter forappIdis correct
The added<if>block cleanly integratesapp_idfiltering, matching the pattern used for other fields.
95-97: Update clause forapp_idis correctly added
The<if>block ensuresapp_idis only updated when non-null, consistent with other conditional set clauses.
165-165: Result mapping forapp_idis correct
Mapping theapp_idcolumn to theappIdproperty aligns with the entity and naming conventions inComponentLibrary.
228-228: Select clause includesapp_id
TheCL.app_idprojection is properly inserted into the select list, ensuring the field is loaded inqueryAllComponentLibrary.
384-385: Insert statement updated to includeapp_id
Both the column list and the corresponding value placeholder forapp_id(#{appId}) are correctly added, preserving alignment with the entity and table schema.Also applies to: 409-410
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes
Tests